package com.yxdj.user.api;

import com.yxdj.common.core.constant.SecurityConstants;
import com.yxdj.common.core.constant.ServiceNameConstants;
import com.yxdj.common.core.domain.R;
import com.yxdj.user.api.domain.Address;
import com.yxdj.user.api.factory.RemoteAddressFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

/**
 * @author 韩总
 */
@FeignClient(contextId = "remoteAddressService",value = ServiceNameConstants.USER_SERVICE, fallbackFactory = RemoteAddressFallbackFactory.class)
public interface RemoteAddressService {

    /**
     * 根据用户id获取用户所有地址信息
     * @param userId
     * @return
     */
    @GetMapping("/address/app/getUserAddressByUserId/{userId}")
    R<List<Address>> getUserAddressByUserId(@PathVariable(name = "userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据地址id获取地址信息
     * @param id
     * @return
     */
    @GetMapping("/address/app/getAddressById/{id}")
    R<Address> getAddressById(@PathVariable(name = "id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
